import Vue from 'vue'
import infoDialog from '@/components/public/loginPop.vue'
import Bus from '@/common/js/vueBus.js';
const Pop = Vue.extend(infoDialog);

export default {
    showLoginPanel : function (message) {
        var self =this;
        var options = {
            el: document.createElement('div'),
            data:{
            }
        };

        if (!this.instancePop) {
            this.instancePop = new Pop(options);
            document.body.appendChild(this.instancePop.$el);
            // this.alertTimeout = setTimeout(function(){
            //      self.destroyInstance();
            // },2000)
        }
        //监听用户登录成功
        Bus.$on("login-succ",function(value){
            if (value) {
                self.destroyInstance();
            }
        });
    },
    instancePop:null,
    destroyInstance:function(){
        var self = this;
        document.body.removeChild(self.instancePop.$el);
        self.instancePop.$destroy();
        self.instancePop = null;
    },

}